USE [QLNS]
GO
/****** Object:  StoredProcedure [dbo].[sp_InsertContract]    Script Date: 07/17/2011 11:31:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

/*********** STORE PROCEDURE INSERT DELETE ************/

/**** CONTRACT ****/
GO
GO
IF OBJECT_ID ('[sp_InsertContract]', 'p') IS NOT NULL
	DROP PROC sp_InsertContract;
GO
CREATE PROCEDURE sp_InsertContract  
    @Contract_Name nvarchar(50),
    @Contract_Des nvarchar(500),
    @UserInsert int,
    @DateInsert datetime,
    @UserUpdate int,
    @DateUpdate datetime
AS
BEGIN
	SET NOCOUNT ON;
	insert into Contract (Contract_Name,Contract_Des,UserInsert,DateInsert,UserUpdate,DateUpdate) 
		   values(@Contract_Name,@Contract_Des,@UserInsert,@DateInsert,@UserUpdate,@DateUpdate)

END
GO
IF OBJECT_ID ('[sp_DeleteContract]', 'p') IS NOT NULL
	DROP PROC sp_DeleteContract;
GO

GO
CREATE PROCEDURE sp_DeleteContract  
	@id int
AS
BEGIN
	SET NOCOUNT ON;
    delete from Contract where Contract_Id = @id 
END

/**** DIPLOMAS ****/
GO
GO
IF OBJECT_ID ('[sp_InsertDiplomas]', 'p') IS NOT NULL
	DROP PROC sp_InsertDiplomas;
GO

CREATE PROCEDURE sp_InsertDiplomas 
	@Diplomas_Name nvarchar(255),
	@UserInsert int ,
	@DateInsert datetime,
	@UserUpdate int ,
	@DateUpdate datetime
AS
BEGIN
	SET NOCOUNT ON;
     insert into Diplomas(
			Diplomas_Name ,
			UserInsert ,
			DateInsert,
			UserUpdate,
			DateUpdate
     )values(
			@Diplomas_Name ,
			@UserInsert,
			@DateInsert,
			@UserUpdate,
			@DateUpdate
     )     
END
GO
IF OBJECT_ID ('[sp_DeleteDiplomas]', 'p') IS NOT NULL
	DROP PROC sp_DeleteDiplomas;
GO
GO
CREATE PROCEDURE sp_DeleteDiplomas
	@id int
AS
BEGIN
	SET NOCOUNT ON;
    delete from Diplomas where Diplomas_Id = @id
END

/**** DISTRICT ****/
GO

GO
IF OBJECT_ID ('[sp_InsertDistrict]', 'p') IS NOT NULL
	DROP PROC sp_InsertDistrict;
GO
create PROCEDURE sp_InsertDistrict 
    @DistrictName nvarchar(250),
    @ProvinceId int,
    @UserInsert int,
    @DateInsert datetime,
    @UserUpdate int,
    @DateUpdate datetime
AS
BEGIN
	SET NOCOUNT ON;
     insert into District(
			DistrictName ,
			ProvinceId ,
			UserInsert ,
			DateInsert ,
			UserUpdate, 
			DateUpdate	
     )values(
			@DistrictName ,
			@ProvinceId ,
			@UserInsert,
		    @DateInsert ,
		    @UserUpdate,
		    @DateUpdate
     )     
END

GO
GO
IF OBJECT_ID ('[sp_DeleteDistrict]', 'p') IS NOT NULL
	DROP PROC sp_DeleteDistrict;
GO
CREATE PROCEDURE sp_DeleteDistrict  
	@id int

AS
BEGIN
	SET NOCOUNT ON;
    delete from District where DistrictId = @id
END

/**** PROVINCE ****/
GO
GO
IF OBJECT_ID ('[sp_InsertProvince]', 'p') IS NOT NULL
	DROP PROC sp_InsertProvince;
GO
create PROCEDURE sp_InsertProvince  
    @ProvinceName nvarchar(250),
    @UserInsert int,
    @DateInsert datetime,
    @UserUpdate int,
    @DateUpdate datetime
AS
BEGIN
	SET NOCOUNT ON;
     insert into Province(
			ProvinceName ,
			UserInsert ,
			DateInsert ,
			UserUpdate ,
			DateUpdate 	
     )values(
			@ProvinceName ,
			@UserInsert ,
			@DateInsert ,
			@UserUpdate ,
			@DateUpdate 	
     )     
END

GO
GO
IF OBJECT_ID ('[sp_DeleteProvince]', 'p') IS NOT NULL
	DROP PROC sp_DeleteProvince;
GO
CREATE PROCEDURE sp_DeleteProvince
	@id int
AS
BEGIN
	SET NOCOUNT ON;
    delete from Province  where   ProvinceId = @id 
END

/**** SPECIALIZED ****/
GO
GO
IF OBJECT_ID ('[sp_InsertSpecialized]', 'p') IS NOT NULL
	DROP PROC sp_InsertSpecialized;
GO
create PROCEDURE sp_InsertSpecialized  
    @Specialized_Name nvarchar(250),
    @UserInsert int,
    @DateInsert datetime,
    @UserUpdate int,
    @DateUpdate datetime
AS
BEGIN
	SET NOCOUNT ON;
     insert into Specialized(
			Specialized_Name ,
			UserInsert ,
			DateInsert ,
			UserUpdate ,
			DateUpdate 	
     )values(
			@Specialized_Name ,
			@UserInsert ,
			@DateInsert ,
			@UserUpdate ,
			@DateUpdate 	
     )     
END

GO
GO
IF OBJECT_ID ('[sp_DeleteSpecialized]', 'p') IS NOT NULL
	DROP PROC [sp_DeleteSpecialized];
GO
CREATE PROCEDURE [dbo].[sp_DeleteSpecialized]  
	@id int
AS
BEGIN
	SET NOCOUNT ON;
    delete from Specialized  where   Specialized_Id = @id 
END